package cn.jflow.boot.controller.App;


import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * 测试使用
 */
@RestController
@CrossOrigin(maxAge = 3600)
@RequestMapping("/WF/test")
public class TestController {
    public static Object Return_Info(int code, String msg, Object data)
    {
        Hashtable ht = new Hashtable();
        ht.put("code", code);
        ht.put("message", msg);
        ht.put("data", data);
        return ht;
    }
    @PostMapping("/test")
    public Object test(String WorkID,String FlowNo){
        System.out.println("workid:"+WorkID);
        System.out.println("FlowNo:"+FlowNo);

        return null;
    }
    //事件webapi调用
    @GetMapping("/getParams")
    public Object getAllParams(HttpServletRequest request,String iserr) {
        Map<String, String> params = new HashMap<>();
        Enumeration<String> parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String paramName = parameterNames.nextElement();
            String paramValue = request.getParameter(paramName);
            System.out.println("key:"+paramName+"   value:"+paramValue);
            params.put(paramName, paramValue);
        }
        if(iserr.equals("1")){
           return Return_Info( 200,"事件执行成功","");
        }else{
            return  Return_Info( 500,"事件执行失败","错误描述****");
        }
    }

}

